﻿namespace ImapComponent.Net.Mail.Imap4
{
    using System;

    #region Delegates

    /// <summary>
    /// EventHandler to be used with the Connecting event.
    /// </summary>
    public delegate void ConnectingEventHandler(object sender);

    /// <summary>
    /// EventHandler to be used with the Connected event.
    /// </summary>
    public delegate void ConnectedEventHandler(object sender, ConnectedEventArgs e);

    /// <summary>
    /// EventHandler to be used with the Authenticating event.
    /// </summary>
    public delegate void AuthenticatingEventHandler(object sender, AuthenticatingEventArgs e);

    /// <summary>
    /// EventHandler to be used with the Authenticated event.
    /// </summary>
    public delegate void AuthenticatedEventHandler(object sender, AuthenticatedEventArgs e);

    /// <summary>
    /// EventHandler to be used with the TcpReading event.
    /// </summary>
    public delegate void TcpReadingEventHandler(object sender);

    /// <summary>
    /// EventHandler to be used with the TcpRead event.
    /// </summary>
    public delegate void TcpReadEventHandler(object sender, TcpReadEventArgs e);

    /// <summary>
    /// EventHandler to be used with the TcpWriting event.
    /// </summary>
    public delegate void TcpWritingEventHandler(object sender, TcpWritingEventArgs e);

    /// <summary>
    /// EventHandler to be used with the TcpWritten event.
    /// </summary>
    public delegate void TcpWrittenEventHandler(object sender, TcpWrittenEventArgs e);

    /// <summary>
    /// EventHandler to be used with the Nooping event.
    /// </summary>
    public delegate void NoopingEventHandler(object sender);

    /// <summary>
    /// EventHandler to be used with the Nooped event.
    /// </summary>
    public delegate void NoopedEventHandler(object sender);

    /// <summary>
    /// EventHandler to be used with the MessageStatusReceived event.
    /// </summary>
    public delegate void MessageStatusReceivedEventHandler(object sender, MessageStatusReceivedEventArgs e);

    /// <summary>
    /// EventHandler to be used with the Disconnecting event.
    /// </summary>
    public delegate void DisconnectingEventHandler(object sender);

    /// <summary>
    /// EventHandler to be used with the Disconnected event.
    /// </summary>
    public delegate void DisconnectedEventHandler(object sender, DisconnectedEventArgs e);

    #endregion // Delegates

    #region Event Arguments

    /// <summary>
    /// EventArgs used by the Connected event.
    /// </summary>
    public class ConnectedEventArgs : EventArgs
    {
        #region Fields

        private readonly string serverResponse;

        #endregion // Fields

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the ConnectedEventArgs class.
        /// </summary>
        /// <param name="serverResponse">The remote server's response.</param>
        public ConnectedEventArgs(string serverResponse)
        {
            this.serverResponse = serverResponse;
        }

        #endregion // Constructors

        #region Properties

        /// <summary>
        /// Gets the remote server's response.
        /// </summary>
        public string ServerResponse
        {
            get
            {
                return this.serverResponse;
            }
        }

        #endregion // Properties
    }

    /// <summary>
    /// EventArgs used by the Authenticating event.
    /// </summary>
    public class AuthenticatingEventArgs : EventArgs
    {
        #region Fields

        private readonly string username;
        private readonly string password;

        #endregion // Fields

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the AuthenticatingEventArgs class.
        /// </summary>
        /// <param name="username">The username used to authenticate the user.</param>
        /// <param name="password">The password used to authenticate the user.</param>
        public AuthenticatingEventArgs(string username, string password)
        {
            this.username = username;
            this.password = password;
        }

        #endregion // Constructors

        #region Properties

        /// <summary>
        /// Gets the username used to authenticate the user.
        /// </summary>
        public string Username
        {
            get
            {
                return this.username;
            }
        }

        /// <summary>
        /// Gets the password used to authenticate the user.
        /// </summary>
        public string Password
        {
            get
            {
                return this.password;
            }
        }

        #endregion // Properties
    }

    /// <summary>
    /// EventArgs used by the Authenticated event.
    /// </summary>
    public class AuthenticatedEventArgs : EventArgs
    {
        #region Fields

        private readonly string username;
        private readonly string password;

        #endregion // Fields

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the AuthenticatedEventArgs class.
        /// </summary>
        /// <param name="username">The username used to authenticate the user.</param>
        /// <param name="password">The password used to authenticate the user.</param>
        public AuthenticatedEventArgs(string username, string password)
        {
            this.username = username;
            this.password = password;
        }

        #endregion // Constructors

        #region Properties

        /// <summary>
        /// Gets the username used to authenticate the user.
        /// </summary>
        public string Username
        {
            get
            {
                return this.username;
            }
        }

        /// <summary>
        /// Gets the password used to authenticate the user.
        /// </summary>
        public string Password
        {
            get
            {
                return this.password;
            }
        }

        #endregion // Properties
    }

    /// <summary>
    /// EventArgs used by the TcpRead event.
    /// </summary>
    public class TcpReadEventArgs : EventArgs
    {
        #region Fields

        private readonly string data;

        #endregion // Fields

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the TcpReadEventArgs class.
        /// </summary>
        /// <param name="data">Data received from the server.</param>
        public TcpReadEventArgs(string data)
        {
            this.data = data;
        }

        #endregion // Constructors

        #region Properties

        /// <summary>
        /// Gets data received from the server.
        /// </summary>
        public string Data
        {
            get
            {
                return this.data;
            }
        }

        #endregion // Properties
    }

    /// <summary>
    /// EventArgs used by the TcpWriting event.
    /// </summary>
    public class TcpWritingEventArgs : EventArgs
    {
        #region Fields

        private readonly string data;

        #endregion // Fields

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the TcpWritingEventArgs class.
        /// </summary>
        /// <param name="data">Data sending to the server.</param>
        public TcpWritingEventArgs(string data)
        {
            this.data = data;
        }

        #endregion // Constructors

        #region Properties

        /// <summary>
        /// Gets data sending to the server.
        /// </summary>
        public string Data
        {
            get
            {
                return this.data;
            }
        }

        #endregion // Properties
    }

    /// <summary>
    /// EventArgs used by the TcpWritten event.
    /// </summary>
    public class TcpWrittenEventArgs : EventArgs
    {
        #region Fields

        private readonly string data;

        #endregion // Fields

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the TcpWrittenEventArgs class.
        /// </summary>
        /// <param name="data">Data sent to the server.</param>
        public TcpWrittenEventArgs(string data)
        {
            this.data = data;
        }

        #endregion // Constructors

        #region Properties

        /// <summary>
        /// Gets data sent to the server.
        /// </summary>
        public string Data
        {
            get
            {
                return this.data;
            }
        }

        #endregion // Properties
    }

    /// <summary>
    /// EventArgs used by the MessageStatusReceived event.
    /// </summary>
    public class MessageStatusReceivedEventArgs : EventArgs
    {
        #region Fields

        private readonly MessageStatusState state;
        private readonly int messageCountOrSequenceNumber;
        private readonly MessageFlagSet flags;

        #endregion // Fields

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the MessageStatusReceivedEventArgs class.
        /// </summary>
        /// <param name="state">The state of the message status.</param>
        /// <param name="messageCountOrSequenceNumber">The message count or the sequence message number.</param>
        /// <param name="flags">A new flag set for the specified message.</param>
        public MessageStatusReceivedEventArgs(MessageStatusState state, int messageCountOrSequenceNumber, MessageFlagSet flags)
        {
            this.state = state;
            this.messageCountOrSequenceNumber = messageCountOrSequenceNumber;
            this.flags = flags;
        }

        #endregion // Constructors

        #region Properties

        /// <summary>
        /// Gets the state of the message status.
        /// </summary>
        public MessageStatusState State
        {
            get
            {
                return this.state;
            }
        }

        /// <summary>
        /// Gets the message count or the sequence message number.
        /// </summary>
        public int MessageCountOrSequenceNumber
        {
            get
            {
                return this.messageCountOrSequenceNumber;
            }
        }

        /// <summary>
        /// Gets a new flag set for the specified message.
        /// </summary>
        public MessageFlagSet Flags
        {
            get
            {
                return this.flags;
            }
        }

        #endregion // Properties
    }

    /// <summary>
    /// EventArgs used by the Disconnected event.
    /// </summary>
    public class DisconnectedEventArgs : EventArgs
    {
        #region Fields

        private readonly string serverResponse;

        #endregion // Fields

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the DisconnectedEventArgs class.
        /// </summary>
        /// <param name="serverresponse">The remote server's response.</param>
        public DisconnectedEventArgs(string serverResponse)
        {
            this.serverResponse = serverResponse;
        }

        #endregion // Constructors

        #region Properties

        /// <summary>
        /// Gets the remote server's response.
        /// </summary>
        public string ServerResponse
        {
            get
            {
                return this.serverResponse;
            }
        }

        #endregion // Properties
    }

    #endregion // Event Arguments
}
